package vote.ai.controller;

import org.springframework.ai.chat.client.ChatClient;
import org.springframework.ai.chat.model.ChatModel;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;
import vote.ai.constant.PromptConstant;

@RestController
public class ChatController {
    private final   ChatModel chatModel;
    private final ChatClient chatClient;

    public ChatController(ChatModel chatModel) {
        this.chatModel = chatModel;
        this.chatClient=ChatClient.builder(chatModel).build();
    }
    @GetMapping("/vote/chat/{text}")
    public String chat(@PathVariable String text) {
        return this.chatClient.prompt(PromptConstant.WORD_CORRECTION+text)
                .call()
                .content();
    }
}
